/*
 * FilterCharset.java
 *
 * Created on 16 de marzo de 2007, 22:58
 *
 * Copyright(c) 2007 Duam Sistemas.
 * All Rights Reserved.
 * This software is the proprietary information of Duam Sistemas.
 */
package org.fiel.filters;

import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;

/**
 * @author Duam Sistemas (http://www.duamsistemas.com.ar)
 */
public class FilterCharset implements Filter
{
    private String encoding;
    
    public void init(FilterConfig config) throws ServletException
    {
        encoding = config.getInitParameter("requestEncoding");
        
        if( encoding==null )
        {
            encoding = "UTF-8";
        }
    }
    
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain next)
    throws IOException, ServletException
    {
        request.setCharacterEncoding(encoding);
        next.doFilter(request, response);
    }
    
    public void destroy()
    {
    }
    
}